/**
 * 
 */
package ptvv.sample;

import java.util.Calendar;

import ptvv.*;

/**
 * @author dkz
 * 
 */
public class Move extends DefaultAutomata {
	protected OutputPort outputPort2;
	// variables needed for computation
	String message;

	public Move() {
		this.setName("Move");

		// outputPort = new OutputPort(destination, dest);

	}

	public void starting() throws InterruptedException {

		eventQueue.take(); // waiting for start
		// System.out.println(item);

	}

	public void ready() throws InterruptedException {
		message = inputPort.take();
	}

	public void running() throws InterruptedException {
		Calendar cal = Calendar.getInstance();
		int count = 0;
		try {
			while (true) {
				Thread.sleep(1000);
				count++;
				// logger.log("Moving in direction: " + message + " for: " +
				// count
				// + "seconds");
			}

		} catch (InterruptedException ie) {
			// logger.log("Moving Interrupted");
		}

		// System.out.println("sleeping..");
		// System.out.println("awake");
		// this.internalState = InternalStates.Suspended;
	}

	public void suspended() throws InterruptedException {

	}

	public void end() {
		// // System.out.println("end");
		logger.log(this.getName() + ": " + message);
		outputPort.destAutomata.addEvent("Start");
		// outputPort2.destAutomata.addInput("2");
		//
		// // System.out.println(outputPort.destination.internalState);
		//
		// // System.out.println(outputPort.destination.isInterrupted());
		//
		// outputPort.destAutomata.addEvent("START");
		// outputPort2.destAutomata.addEvent("START");
		repeatBool = true;
	}

	public void dead() {
		// this.internalState = InternalStates.Start;

	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {

	}

}
